package practice1_100;

public class Practice283 {
    //双指针，slow和fast，快指针先走做便利，slow指针负责存储不为0的数字，快指针遍历完，再将慢指针后面的填充为0
    public void moveZeroes(int[] nums) {
        int slow=0,fast=0,len= nums.length;
        for (; fast < len; fast++) {
            if(nums[fast]!=0) {
                nums[slow] = nums[fast];
                slow++;
            }
        }
        while (slow< len){
            nums[slow]=0;
            slow++;
        }
        System.out.println(nums);
    }

    public static void main(String[] args) {
        new Practice283().moveZeroes(new int[]{3,0,4,53,4,2,3,2,0,3,7,9,3,0,0,0,6,4,46,2,6,0,26,4,65,4,4,2,});
    }
}
